home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / other / jikes-1.11 / src / getclass.h < prev    next >
C/C++ Source or Header  |  2000-02-23  |  4KB  |  148 lines

  1. // $Id: getclass.h,v 1.4 1999/08/26 15:34:08 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef getclass_INCLUDED
  11. #define getclass_INCLUDED
  12.  
  13. #include "config.h"
  14. #include "semantic.h"
  15. #include "long.h"
  16. #include "double.h"
  17.  
  18. class Cp_Info
  19. {
  20. public:
  21.     enum
  22.     {
  23.         CONSTANT_Class              = 7,
  24.         CONSTANT_Fieldref           = 9,
  25.         CONSTANT_Methodref          = 10,
  26.         CONSTANT_InterfaceMethodref = 11,
  27.         CONSTANT_String             = 8,
  28.         CONSTANT_Integer            = 3,
  29.         CONSTANT_Float              = 4,
  30.         CONSTANT_Long               = 5,
  31.         CONSTANT_Double             = 6,
  32.         CONSTANT_NameAndType        = 12,
  33.         CONSTANT_Utf8               = 1
  34.     };
  35.  
  36.     static u1 Tag(char *buffer) { return (u1) *buffer; }
  37. };
  38.  
  39. class Constant_Utf8_info : public Cp_Info
  40. {
  41. public:
  42.     static u2 Length(char *buffer) { return Semantic::GetU2(buffer + 1); } // skip tag
  43.     static char *Bytes(char *buffer) { return buffer + 3; } // skip tag and length
  44. };
  45.  
  46.  
  47. class Constant_Class_info : public Cp_Info
  48. {
  49. public:
  50.     static u2 NameIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  51. };
  52.  
  53.  
  54. class Constant_Fieldref_info : public Cp_Info
  55. {
  56. public:
  57.     static u2 ClassIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  58.     static u2 NameAndTypeIndex(char *buffer) { return Semantic::GetU2(buffer + 3); }
  59. };
  60.  
  61.  
  62. class Constant_Methodref_info : public Cp_Info
  63. {
  64. public:
  65.     static u2 ClassIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  66.     static u2 NameAndTypeIndex(char *buffer) { return Semantic::GetU2(buffer + 3); }
  67. };
  68.  
  69.  
  70. class Constant_InterfaceMethodref_info : public Cp_Info
  71. {
  72. public:
  73.     static u2 ClassIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  74.     static u2 NameAndTypeIndex(char *buffer) { return Semantic::GetU2(buffer + 3); }
  75. };
  76.  
  77.  
  78. class Constant_NameAndType_info : public Cp_Info
  79. {
  80. public:
  81.     static u2 NameIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  82.     static u2 DescriptorIndex(char *buffer) { return Semantic::GetU2(buffer + 3); }
  83. };
  84.  
  85.  
  86. class Constant_String_info : public Cp_Info
  87. {
  88. public:
  89.     static u2 StringIndex(char *buffer) { return Semantic::GetU2(buffer + 1); }
  90. };
  91.  
  92.  
  93. class Constant_Integer_info : public Cp_Info
  94. {
  95. public:
  96.     static u4 Bytes(char *buffer) { return Semantic::GetU4(buffer + 1); }
  97.  
  98.     static int Value(char *buffer)
  99.     {
  100.         union field
  101.         {
  102.             u4 u;
  103.             int i;
  104.         } value;
  105.         value.u = Bytes(buffer);
  106.         return value.i;
  107.     }
  108. };
  109.  
  110.  
  111. class Constant_Float_info : public Cp_Info
  112. {
  113. public:
  114.     static u4 Bytes(char *buffer) { return Semantic::GetU4(buffer + 1); }
  115.  
  116.     static IEEEfloat Value(char *buffer)
  117.     {
  118.         return IEEEfloat(Semantic::GetU4(buffer+1));
  119.     }
  120. };
  121.  
  122.  
  123. class Constant_Long_info : public Cp_Info
  124. {
  125. public:
  126.     static u4 HighBytes(char *buffer) { return Semantic::GetU4(buffer + 1); }
  127.     static u4 LowBytes(char *buffer) { return Semantic::GetU4(buffer + 5); }
  128.  
  129.     static LongInt Value(char *buffer)
  130.     {
  131.         return LongInt(HighBytes(buffer), LowBytes(buffer));
  132.     }
  133. };
  134.  
  135.  
  136. class Constant_Double_info : public Cp_Info
  137. {
  138. public:
  139.     static u4 HighBytes(char *buffer) { return Semantic::GetU4(buffer + 1); }
  140.     static u4 LowBytes(char *buffer) { return Semantic::GetU4(buffer + 5); }
  141.  
  142.     static IEEEdouble Value(char *buffer)
  143.     {
  144.         return IEEEdouble(HighBytes(buffer), LowBytes(buffer));
  145.     }
  146. };
  147. #endif
  148.